import axios from "axios";
// import QS from "qs";
//设置http请求的一个超时时间
axios.defaults.timeout = 10000;
//设置http的请求头
axios.defaults.headers.post["Content-Type"] = "application/json";
//响应拦截器
axios.interceptors.response.use(
    response => {
        if (response.status == 200) {
            return Promise.resolve(response);
        } else {
            return Promise.reject(response)
        }
    }
)

export function post(url, params) {
    return new Promise((resolve, reject) => {
        console.log(params)
        console.log(typeof(params))
        axios.post(url, params).then(
            (res) => {
                resolve(res.data)
            }
        ).catch(
            (err) => {
                console.log(err)
                reject(err.data);
            }
        )
    })
}